using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Reflection;

namespace ZX.BLL.ClientMobi.Message
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class DatSysNewsMonthInfoInfo
    {
        #region 属性
        private String _iD = Guid.NewGuid().ToString();
        /// <summary>
        /// 
        /// </summary>
        public String ID
        {
            get{return _iD;}
            set{_iD = value;}
        }
        
        private string _proposer = "";
        /// <summary>
        /// 申请人
        /// </summary>
        public string Proposer
        {
            get{return _proposer;}
            set{_proposer = value;}
        }
        
        private string _filiale = "";
        /// <summary>
        /// 所属分公司
        /// </summary>
        public string Filiale
        {
            get{return _filiale;}
            set{_filiale = value;}
        }
        
        private string _deptID = "";
        /// <summary>
        /// 所属部门ID
        /// </summary>
        public string DeptID
        {
            get{return _deptID;}
            set{_deptID = value;}
        }
        
        private string _deptName = "";
        /// <summary>
        /// 所属部门
        /// </summary>
        public string DeptName
        {
            get{return _deptName;}
            set{_deptName = value;}
        }
        
        private string _postID = "";
        /// <summary>
        /// 所属岗位ID
        /// </summary>
        public string PostID
        {
            get{return _postID;}
            set{_postID = value;}
        }
        
        private string _postName = "";
        /// <summary>
        /// 所属岗位
        /// </summary>
        public string PostName
        {
            get{return _postName;}
            set{_postName = value;}
        }
        
        private string _createdTime = "";
        /// <summary>
        /// 申请时间
        /// </summary>
        public string CreatedTime
        {
            get{return _createdTime;}
            set{_createdTime = value;}
        }
        
        private string _workFlowId = "";
        /// <summary>
        /// 流程模板ID
        /// </summary>
        public string WorkFlowId
        {
            get{return _workFlowId;}
            set{_workFlowId = value;}
        }
        
        private string _workFlowInsId = "";
        /// <summary>
        /// 流程实例ID
        /// </summary>
        public string WorkFlowInsId
        {
            get{return _workFlowInsId;}
            set{_workFlowInsId = value;}
        }
        
        private string _workTaskId = "";
        /// <summary>
        /// 流程模板任务ID
        /// </summary>
        public string WorkTaskId
        {
            get{return _workTaskId;}
            set{_workTaskId = value;}
        }
        
        private string _workTaskInsId = "";
        /// <summary>
        /// 流程任务实例ID
        /// </summary>
        public string WorkTaskInsId
        {
            get{return _workTaskInsId;}
            set{_workTaskInsId = value;}
        }
        
        private string _bpmTitle = "";
        /// <summary>
        /// 标题
        /// </summary>
        public string BpmTitle
        {
            get{return _bpmTitle;}
            set{_bpmTitle = value;}
        }
        
        private String _nID = Guid.NewGuid().ToString();
        /// <summary>
        /// SysNews的编号
        /// </summary>
        public String NID
        {
            get{return _nID;}
            set{_nID = value;}
        }
        
        private String _recevePeopleID = Guid.NewGuid().ToString();
        /// <summary>
        /// 接收人编号
        /// </summary>
        public String RecevePeopleID
        {
            get{return _recevePeopleID;}
            set{_recevePeopleID = value;}
        }
        
        private DateTime _readDate = DateTime.Parse("1900-1-1");
        /// <summary>
        /// 阅读时间
        /// </summary>
        public DateTime ReadDate
        {
            get{return _readDate;}
            set{_readDate = value;}
        }
        
        private bool _isDelete = false;
        /// <summary>
        /// 是否删除【0是未删除；1是已删除】
        /// </summary>
        public bool IsDelete
        {
            get{return _isDelete;}
            set{_isDelete = value;}
        }
        
        private DateTime _addTime = DateTime.Parse("1900-1-1");
        /// <summary>
        /// 发送时间
        /// </summary>
        public DateTime AddTime
        {
            get{return _addTime;}
            set{_addTime = value;}
        }
        
        #endregion
        
        #region 构造函数
        public DatSysNewsMonthInfoInfo()
        {}
        
        public DatSysNewsMonthInfoInfo
        (
            String iD,
            string proposer,
            string filiale,
            string deptID,
            string deptName,
            string postID,
            string postName,
            string createdTime,
            string workFlowId,
            string workFlowInsId,
            string workTaskId,
            string workTaskInsId,
            string bpmTitle,
            String nID,
            String recevePeopleID,
            DateTime readDate,
            bool isDelete,
            DateTime addTime
        )
        {
            _iD = iD;
            _proposer = proposer;
            _filiale = filiale;
            _deptID = deptID;
            _deptName = deptName;
            _postID = postID;
            _postName = postName;
            _createdTime = createdTime;
            _workFlowId = workFlowId;
            _workFlowInsId = workFlowInsId;
            _workTaskId = workTaskId;
            _workTaskInsId = workTaskInsId;
            _bpmTitle = bpmTitle;
            _nID = nID;
            _recevePeopleID = recevePeopleID;
            _readDate = readDate;
            _isDelete = isDelete;
            _addTime = addTime;
        }
        #endregion
        
        #region 填充数据实体
        /// <summary>
        /// 得到DatSysNewsMonthInfoInfo数据实体
        /// </summary>
        /// <param name="row">row</param>
        /// <returns>DatSysNewsMonthInfoInfo数据实体</returns>
        public static DatSysNewsMonthInfoInfo PopulateFromDataRow(DataRow row)
        {
            DatSysNewsMonthInfoInfo obj = new DatSysNewsMonthInfoInfo();
            if (row != null)
            {
                obj.ID = row["ID"] == DBNull.Value ? Guid.NewGuid().ToString() : Convert.ToString(row["ID"]);   
                obj.Proposer = row["Proposer"] == DBNull.Value ? "" : Convert.ToString(row["Proposer"]);   
                obj.Filiale = row["Filiale"] == DBNull.Value ? "" : Convert.ToString(row["Filiale"]);   
                obj.DeptID = row["DeptID"] == DBNull.Value ? "" : Convert.ToString(row["DeptID"]);   
                obj.DeptName = row["DeptName"] == DBNull.Value ? "" : Convert.ToString(row["DeptName"]);   
                obj.PostID = row["PostID"] == DBNull.Value ? "" : Convert.ToString(row["PostID"]);   
                obj.PostName = row["PostName"] == DBNull.Value ? "" : Convert.ToString(row["PostName"]);   
                obj.CreatedTime = row["CreatedTime"] == DBNull.Value ? "" : Convert.ToString(row["CreatedTime"]);   
                obj.WorkFlowId = row["WorkFlowId"] == DBNull.Value ? "" : Convert.ToString(row["WorkFlowId"]);   
                obj.WorkFlowInsId = row["WorkFlowInsId"] == DBNull.Value ? "" : Convert.ToString(row["WorkFlowInsId"]);   
                obj.WorkTaskId = row["WorkTaskId"] == DBNull.Value ? "" : Convert.ToString(row["WorkTaskId"]);   
                obj.WorkTaskInsId = row["WorkTaskInsId"] == DBNull.Value ? "" : Convert.ToString(row["WorkTaskInsId"]);   
                obj.BpmTitle = row["bpmTitle"] == DBNull.Value ? "" : Convert.ToString(row["bpmTitle"]);   
                obj.NID = row["NID"] == DBNull.Value ? Guid.NewGuid().ToString() : Convert.ToString(row["NID"]);   
                obj.RecevePeopleID = row["recevePeopleID"] == DBNull.Value ? Guid.NewGuid().ToString() : Convert.ToString(row["recevePeopleID"]);   
                obj.ReadDate = row["readDate"] == DBNull.Value ? DateTime.Parse("1900-1-1") : Convert.ToDateTime(row["readDate"]);   
                obj.IsDelete = row["IsDelete"] == DBNull.Value ? false : Convert.ToBoolean(row["IsDelete"]);   
                obj.AddTime = row["AddTime"] == DBNull.Value ? DateTime.Parse("1900-1-1") : Convert.ToDateTime(row["AddTime"]);   
            }
            else
            {
                return null;
            }
            return obj;
        }
        
        /// <summary>
        /// 得到DatSysNewsMonthInfoInfo数据实体
        /// </summary>
        /// <param name="reader">reader</param>
        /// <returns>DatSysNewsMonthInfoInfo数据实体</returns>
        public static DatSysNewsMonthInfoInfo PopulateFromReader(IDataReader reader)
        {
            DatSysNewsMonthInfoInfo obj = new DatSysNewsMonthInfoInfo();
            
            obj.ID = reader["ID"] == DBNull.Value ? Guid.NewGuid().ToString() : Convert.ToString(reader["ID"]);
            obj.Proposer = reader["Proposer"] == DBNull.Value ? "" : Convert.ToString(reader["Proposer"]);
            obj.Filiale = reader["Filiale"] == DBNull.Value ? "" : Convert.ToString(reader["Filiale"]);
            obj.DeptID = reader["DeptID"] == DBNull.Value ? "" : Convert.ToString(reader["DeptID"]);
            obj.DeptName = reader["DeptName"] == DBNull.Value ? "" : Convert.ToString(reader["DeptName"]);
            obj.PostID = reader["PostID"] == DBNull.Value ? "" : Convert.ToString(reader["PostID"]);
            obj.PostName = reader["PostName"] == DBNull.Value ? "" : Convert.ToString(reader["PostName"]);
            obj.CreatedTime = reader["CreatedTime"] == DBNull.Value ? "" : Convert.ToString(reader["CreatedTime"]);
            obj.WorkFlowId = reader["WorkFlowId"] == DBNull.Value ? "" : Convert.ToString(reader["WorkFlowId"]);
            obj.WorkFlowInsId = reader["WorkFlowInsId"] == DBNull.Value ? "" : Convert.ToString(reader["WorkFlowInsId"]);
            obj.WorkTaskId = reader["WorkTaskId"] == DBNull.Value ? "" : Convert.ToString(reader["WorkTaskId"]);
            obj.WorkTaskInsId = reader["WorkTaskInsId"] == DBNull.Value ? "" : Convert.ToString(reader["WorkTaskInsId"]);
            obj.BpmTitle = reader["bpmTitle"] == DBNull.Value ? "" : Convert.ToString(reader["bpmTitle"]);
            obj.NID = reader["NID"] == DBNull.Value ? Guid.NewGuid().ToString() : Convert.ToString(reader["NID"]);
            obj.RecevePeopleID = reader["recevePeopleID"] == DBNull.Value ? Guid.NewGuid().ToString() : Convert.ToString(reader["recevePeopleID"]);
            obj.ReadDate = reader["readDate"] == DBNull.Value ? DateTime.Parse("1900-1-1") : Convert.ToDateTime(reader["readDate"]);
            obj.IsDelete = reader["IsDelete"] == DBNull.Value ? false : Convert.ToBoolean(reader["IsDelete"]);
            obj.AddTime = reader["AddTime"] == DBNull.Value ? DateTime.Parse("1900-1-1") : Convert.ToDateTime(reader["AddTime"]);
            
            return obj;
        }
        
        /// <summary>
        /// 得到DatSysNewsMonthInfo，DataTable
        /// </summary>
        /// <param name="info">info</param>
        /// <returns>DatSysNewsMonthInfo，DataTable</returns>
        public static DataTable PopulateFromInfo(DatSysNewsMonthInfoInfo info)
        {
            DataTable table = new DataTable("DatSysNewsMonthInfo");
            DataRow row = null;
            
            if (info != null)
            {
                
                table.Columns.Add("ID", typeof(String));
                table.Columns.Add("Proposer", typeof(string));
                table.Columns.Add("Filiale", typeof(string));
                table.Columns.Add("DeptID", typeof(string));
                table.Columns.Add("DeptName", typeof(string));
                table.Columns.Add("PostID", typeof(string));
                table.Columns.Add("PostName", typeof(string));
                table.Columns.Add("CreatedTime", typeof(string));
                table.Columns.Add("WorkFlowId", typeof(string));
                table.Columns.Add("WorkFlowInsId", typeof(string));
                table.Columns.Add("WorkTaskId", typeof(string));
                table.Columns.Add("WorkTaskInsId", typeof(string));
                table.Columns.Add("bpmTitle", typeof(string));
                table.Columns.Add("NID", typeof(String));
                table.Columns.Add("recevePeopleID", typeof(String));
                table.Columns.Add("readDate", typeof(DateTime));
                table.Columns.Add("IsDelete", typeof(bool));
                table.Columns.Add("AddTime", typeof(DateTime));
            
                row = table.NewRow();
            
                row["ID"] = info.ID;
                row["Proposer"] = info.Proposer;
                row["Filiale"] = info.Filiale;
                row["DeptID"] = info.DeptID;
                row["DeptName"] = info.DeptName;
                row["PostID"] = info.PostID;
                row["PostName"] = info.PostName;
                row["CreatedTime"] = info.CreatedTime;
                row["WorkFlowId"] = info.WorkFlowId;
                row["WorkFlowInsId"] = info.WorkFlowInsId;
                row["WorkTaskId"] = info.WorkTaskId;
                row["WorkTaskInsId"] = info.WorkTaskInsId;
                row["bpmTitle"] = info.BpmTitle;
                row["NID"] = info.NID;
                row["recevePeopleID"] = info.RecevePeopleID;
                row["readDate"] = info.ReadDate;
                row["IsDelete"] = info.IsDelete;
                row["AddTime"] = info.AddTime;
                table.Rows.Add(row);
            }

            return table;
        }
        
        /// <summary>
        /// 得到DatSysNewsMonthInfo，DataTable
        /// </summary>
        /// <param name="infoList">infoList</param>
        /// <returns>DatSysNewsMonthInfo，DataTable</returns>
        public static DataTable PopulateFromInfoList(List< DatSysNewsMonthInfoInfo> infoList)
        {
            DataTable table = new DataTable("DatSysNewsMonthInfo");
            DataRow row = null;
            
            if (infoList != null)
            {
                
                table.Columns.Add("ID", typeof(String));
                table.Columns.Add("Proposer", typeof(string));
                table.Columns.Add("Filiale", typeof(string));
                table.Columns.Add("DeptID", typeof(string));
                table.Columns.Add("DeptName", typeof(string));
                table.Columns.Add("PostID", typeof(string));
                table.Columns.Add("PostName", typeof(string));
                table.Columns.Add("CreatedTime", typeof(string));
                table.Columns.Add("WorkFlowId", typeof(string));
                table.Columns.Add("WorkFlowInsId", typeof(string));
                table.Columns.Add("WorkTaskId", typeof(string));
                table.Columns.Add("WorkTaskInsId", typeof(string));
                table.Columns.Add("bpmTitle", typeof(string));
                table.Columns.Add("NID", typeof(String));
                table.Columns.Add("recevePeopleID", typeof(String));
                table.Columns.Add("readDate", typeof(DateTime));
                table.Columns.Add("IsDelete", typeof(bool));
                table.Columns.Add("AddTime", typeof(DateTime));
                
                for(int i = 0; i < infoList.Count; i++)
                {
                    row = table.NewRow();
                
                    row["ID"] = infoList[i].ID;
                    row["Proposer"] = infoList[i].Proposer;
                    row["Filiale"] = infoList[i].Filiale;
                    row["DeptID"] = infoList[i].DeptID;
                    row["DeptName"] = infoList[i].DeptName;
                    row["PostID"] = infoList[i].PostID;
                    row["PostName"] = infoList[i].PostName;
                    row["CreatedTime"] = infoList[i].CreatedTime;
                    row["WorkFlowId"] = infoList[i].WorkFlowId;
                    row["WorkFlowInsId"] = infoList[i].WorkFlowInsId;
                    row["WorkTaskId"] = infoList[i].WorkTaskId;
                    row["WorkTaskInsId"] = infoList[i].WorkTaskInsId;
                    row["bpmTitle"] = infoList[i].BpmTitle;
                    row["NID"] = infoList[i].NID;
                    row["recevePeopleID"] = infoList[i].RecevePeopleID;
                    row["readDate"] = infoList[i].ReadDate;
                    row["IsDelete"] = infoList[i].IsDelete;
                    row["AddTime"] = infoList[i].AddTime;
                    table.Rows.Add(row);
                }
            }

            return table;
        }
        
        /// <summary>
        /// Copy得到DatSysNewsMonthInfoInfo，对象
        /// </summary>
        /// <param name="data">data</param>
        /// <returns>DatSysNewsMonthInfo，对象</returns>
        public static DatSysNewsMonthInfoInfo CopyData<T>(T data) where T : class
        {
            if (data == null) return null;
            
            DatSysNewsMonthInfoInfo info = new DatSysNewsMonthInfoInfo();
            PropertyInfo[] infoProList = info.GetType().GetProperties();
            PropertyInfo[] dataProList = data.GetType().GetProperties();
            
            foreach (PropertyInfo infoPro in infoProList)
            {
                foreach (PropertyInfo dataPro in dataProList)
                {
                    if (infoPro.Name == dataPro.Name && infoPro.PropertyType.FullName == dataPro.PropertyType.FullName)
                    {
                        infoPro.SetValue(info, dataPro.GetValue(data, null), null);
                    }
                }
            }
            
            return info;
        }
        
        #endregion
    }
}


